package com.zhangxun.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

/**
 * 用户表
 * @TableName user
 */
@TableName(value ="user")
@Data
public class WxUser implements Serializable, UserDetails {
    /**
     * ID
     */
    @TableId(value = "user_id")
    private String userId;




    /**
     * 最后登录时间
     */
    @TableField(value = "user_regtime")
    private Date userRegetime;

    /**
     * 最后登录IP
     */
    @TableField(value = "user_lastip")
    private String userLastip;


    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return Collections.emptyList();
    }

    @Override
    public String getPassword() {
        return new BCryptPasswordEncoder().encode("WECHAT");
    }

    @Override
    public String getUsername() {
        return this.userId;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}